{extend name="public/base"/}
{block name="style"}
<style>
.chapter-content p{margin: 0 0 15px;font-size:16px;text-indent:2em;}
</style>
{/block}
{block name="body"}
<div class="main-box clearfix">
	<header class="main-box-header clearfix">
		<div class="pull-left">
			<h2>{$meta_title}</h2>
		</div>
		<div class="pull-right">
			
		</div>
	</header>
	<div class="main-box-body clearfix">
		<div class="row">
			<form method="get">
				<div class="col-sm-12 col-md-4 col-lg-3">
					<input type="text" class="form-control" name="keyword" value="{$keyword|default=''}" placeholder="请输入关键字">
				</div>
				
				<div class="col-sm-12 col-md-4">
					<button class="btn btn-primary" type="submit">搜索</button>
				</div>
			</form>
		</div>
		<div class="table-responsive clearfix">

			<div class="table-responsive clearfix">
				
				<ul class="nav nav-tabs" style="margin-top:20px;">
					<li >
						<a href="{:url('draft')}">普通草稿</a>
					</li>
					<li >
						<a href="{:url('chapter')}">待审章节</a>
					</li>

					<li class="active">
						<a href="{:url('timing')}">定时章节</a>
					</li>

					<li >
						<a href="{:url('reject')}">驳回章节</a>
					</li>
					
				</ul>

				<table class="table table-hover">
					<thead>
						<tr>
							<th width="30"><input class="checkbox check-all" type="checkbox"></th>
							<th>ID</th>
							<th>书籍</th>
							<th>章节名称</th>
							<th>更新</th>
							<th>类型</th>
							<th>状态</th>
							<th>发表者</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody>
						{volist name="list" id="item"}
							<tr>
							<td><input class="ids row-selected" type="checkbox" name="id[]" value="{$item['id']}"></td>
							<td>{$item['id']}</td>
							<td><a href="{:url('admin/chapter/index?model_id=1',array('id'=>$item['articleid']))}" target="_blank">{$item['articlename']}</a></td>
							<td>{$item['chaptername']}</td>
							<td>{$item['update_time']|date='Y-m-d H:i',###}</td>
							<td>{if $item['isvip']==1}VIP{else}免费{/if}</td>
							<td>定时：{$item['publishtime']|date='Y-m-d H:i',###}
							</td>
							<td>{$item['uid']|get_username}</td>
							<td>
							<a data-toggle="view-chapter" data-id="{$item['id']}" data-chaptername="{$item['chaptername']}">查看</a>
							<a href="{:url('admin/chapter/edit?model_id=2',array('id'=>$item['id'],'articleid'=>$item['articleid']))}">编辑</a>
							<a href="{:url('admin/chapter/del?model_id=2',array('id'=>$item['id'],'articleid'=>$item['articleid']))}" class="ajax-get confirm">删除</a>
							<a href="{:url('admin/chapter/status?model_id=2',array('id'=>$item['id'],'status'=>'4'))}" class="ajax-get">驳回</a>
							</td>
							</tr>
						{/volist}
					</tbody>
				</table>
			</div>
			{$page}
		</div>
	</div>
</div>
<div id="view-chapter-modal" class="modal fade" tabindex="-1" role="dialog">
	<div class="modal-dialog" role="document" style="width:1000px">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
				<h4 class="modal-title" data-bind="text: title"></h4>
			</div>
			<div class="modal-body" >
				<div class="chapter-content" style="overflow: auto;" ></div>
			</div>
		</div>
	</div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
<!--
	$(function () {
		$(document).on('click', '[data-toggle="view-chapter"]', function () {
            var id = $(this).data('id'),
				chaptername = $(this).data('chaptername');
            viewChapter(id,chaptername);
            return false;
        });

	})

	function viewChapter(id,chaptername) {
		var $current = $('.list-group-item [data-toggle="view-chapter"][data-id="' + id + '"]');
		
		var prevId = $current.closest('li').prev().find('[data-toggle="view-chapter"]').data('id');
		var prevName = $current.closest('li').prev().find('[data-toggle="view-chapter"]').data('chaptername');

		var nextId = $current.closest('li').next().find('[data-toggle="view-chapter"]').data('id');

		var nextName = $current.closest('li').next().find('[data-toggle="view-chapter"]').data('chaptername');

		$.get('{:url('chapter/api_get_chapter')}', { id: id,chaptername:chaptername,model_id:2}, function (data) {
			var content = data.content;
			content = content.replace(/&nbsp;/ig,"");
            content = content.replace(/[ ]/g,"");
			content = content.replace(/[　]/g,"");
			$('#view-chapter-modal .modal-title').html(data.title);
			$('#view-chapter-modal .chapter-content').html(content);

			
			var $modal = $('#view-chapter-modal');
			//$modal.off('shown.bs.modal').on('shown.bs.modal', createBLazy);
			if ($modal.data('bs.modal') && $modal.data('bs.modal').isShown) {
				$modal.find('.chapter-content').scrollTop(0);
			} else {
				$modal.modal('show');
			}
		},'json');
	}
//-->
</script>

{/block}